package com.ptkc;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.*;

import static java.util.concurrent.Executors.*;

/**
 * @author: Mr.Jiao
 * @date: 2018年09月30日
 */
@SpringBootApplication
//@EnableAsync
public class Application implements AsyncConfigurer {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

//    @Override
//    public Executor getAsyncExecutor() {
//        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
//        // 最小线程数
//        taskExecutor.setCorePoolSize(30);
//        // 最大线程数
//        taskExecutor.setMaxPoolSize(30);
//        // 等待队列
//        taskExecutor.setQueueCapacity(0);
//        taskExecutor.setThreadNamePrefix("runfast_canal_es_executors");
//        taskExecutor.setRejectedExecutionHandler((Runnable r, ThreadPoolExecutor executor)->{
//            System.err.println("线程数已超出预设值" + taskExecutor.getMaxPoolSize());
//            if (!executor.isShutdown()) {
//                try {
//                    executor.getQueue().put(r);
//                } catch (InterruptedException e) {
//                    Thread.currentThread().interrupt();
//                }
//            }
//        });
//        taskExecutor.initialize();
//        return taskExecutor;
//    }

}
